package com.base.hong.ui.web

import android.content.Context
import android.webkit.JavascriptInterface
import com.just.agentweb.AgentWeb


/**
 * @ClassName WebInterface
 * @Description TODO
 * @Author Hong
 * @Date 2022/3/23 17:53
 * @Version 1.0
 */
class LoginWebInterface(agent: AgentWeb?, context: Context?, callback: LoginWebJsCallback?) {
    private var mAgent: AgentWeb? = null

    private var mContext: Context? = null
    private var mInterfaceCallback: LoginWebJsCallback? = null

    init {
        this.mAgent = agent
        this.mContext = context
        this.mInterfaceCallback = callback

    }

    /**
     * 获取Token
     */
    @JavascriptInterface
    fun authLogin(token: String) {
        if (mInterfaceCallback != null) {
            mInterfaceCallback?.setToken(token)
        }
    }

    @JavascriptInterface
    fun dismiss() {
        if (mInterfaceCallback != null) {
            mInterfaceCallback?.onBack()
        }
    }


}